package com.ruoyi.module.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.module.service.IExamQuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.module.mapper.ExamWrongMapper;
import com.ruoyi.module.domain.ExamWrong;
import com.ruoyi.module.service.IExamWrongService;

/**
 * 考试错题记录Service业务层处理
 *
 * @author fubojin
 * @date 2025-03-07
 */
@Service
public class ExamWrongServiceImpl implements IExamWrongService
{
    @Autowired
    private ExamWrongMapper examWrongMapper;

    @Autowired
    private IExamQuestionsService examQuestionsService;

    /**
     * 查询考试错题记录
     *
     * @param id 考试错题记录主键
     * @return 考试错题记录
     */
    @Override
    public ExamWrong selectExamWrongById(Long id)
    {
        return examWrongMapper.selectExamWrongById(id);
    }

    /**
     * 查询考试错题记录列表
     *
     * @param examWrong 考试错题记录
     * @return 考试错题记录
     */
    @Override
    public List<ExamWrong> selectExamWrongList(ExamWrong examWrong)
    {
        List<ExamWrong> examWrongs = examWrongMapper.selectExamWrongList(examWrong);
        for (ExamWrong wrong : examWrongs) {
            wrong.setExamQuestions(examQuestionsService.selectExamQuestionsById(wrong.getQuestionsId()));
        }
        return examWrongs;
    }

    /**
     * 新增考试错题记录
     *
     * @param examWrong 考试错题记录
     * @return 结果
     */
    @Override
    public int insertExamWrong(ExamWrong examWrong)
    {
        examWrong.setCreateTime(DateUtils.getNowDate());
        return examWrongMapper.insertExamWrong(examWrong);
    }

    /**
     * 修改考试错题记录
     *
     * @param examWrong 考试错题记录
     * @return 结果
     */
    @Override
    public int updateExamWrong(ExamWrong examWrong)
    {
        examWrong.setUpdateTime(DateUtils.getNowDate());
        return examWrongMapper.updateExamWrong(examWrong);
    }

    /**
     * 批量删除考试错题记录
     *
     * @param ids 需要删除的考试错题记录主键
     * @return 结果
     */
    @Override
    public int deleteExamWrongByIds(Long[] ids)
    {
        return examWrongMapper.deleteExamWrongByIds(ids);
    }

    /**
     * 删除考试错题记录信息
     *
     * @param id 考试错题记录主键
     * @return 结果
     */
    @Override
    public int deleteExamWrongById(Long id)
    {
        return examWrongMapper.deleteExamWrongById(id);
    }
}
